//
//  BaseViewController.m
//  YXLearnMasonry
//
//  Created by Rookie_YX on 16/10/27.
//  Copyright © 2016年 Rookie_YX. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
  //  red
  UIView * redView = [[UIView alloc]init];
  redView.backgroundColor = [UIColor redColor];
  [self.view addSubview:redView];
  
  // green
  UIView * greenView = [[UIView alloc]init];
  greenView.backgroundColor = [UIColor greenColor];
  [self.view addSubview:greenView];
  
  // blue
  UIView * blueView = [[UIView alloc]init];
  blueView.backgroundColor = [UIColor blueColor];
  [self.view addSubview:blueView];
  
  /// 布局
  [redView  mas_makeConstraints:^(MASConstraintMaker *make) {
//    make.left.equalTo(self.view).offset(20);
//    make.top.equalTo(self.view).offset(20);
//     make.width.equalTo(50);
//     make.height.equalTo(50);
    
    //上4句可以缩写下2句
    make.top.left.equalTo(self.view).offset(20);
    make.width.height.equalTo(50);  //  等同  make.size.equalTo(@50);
  }];
  
  CGFloat padding = 15;
  [greenView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.bottom.equalTo(redView);
    make.left.equalTo(redView.right).offset(padding);
    // 红绿视图高度相宽
      make.width.equalTo(redView.width);
  }];
  
  [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.equalTo(redView);
    make.top.equalTo(redView.bottom).with.offset(padding);  // with 和 and 都是增强可读性
    make.height.equalTo(redView.height).multipliedBy(2);  // 倍数
  }];
}

@end
